import com.example.c3p0.Util.C3p0Util;
import com.example.c3p0.javabean.User;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;


import java.sql.SQLException;

/**
 * @auther 尚智江
 * @Date 2022/5/14 22:45
 */
public class QueryByuser {
    public static void main(String[] args)throws SQLException {
        QueryRunner queryRunner = new QueryRunner(C3p0Util.getDataSource());
        String sql = "SELECT * FROM user WHERE user = 'hello'";

//        int num = queryRunner.update(sql);
//         调用user方法
        User user = (User) queryRunner.query(sql,new BeanHandler<User>(User.class));


        System.out.println("用户名："+user.getUsername()+","+"密码："+user.getPassword());
        System.out.println(user.getPassword());

    }
}
